package com.xayy.mgt.model;

import cn.kawins.mybatis.base.BaseModel;
import cn.kawins.mybatis.interceptor.FillingCreateTime;
import cn.kawins.mybatis.interceptor.InsertAutoFilling;
import cn.kawins.mybatis.interceptor.UpdateAutoFilling;
import cn.kawins.mybatis.util.SnowflakeId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.xayy.mgt.enums.SeriousDegreeEnum;
import io.swagger.annotations.ApiModelProperty;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import lombok.*;

/**
 * 预想故障表(AnticipatoryFailure)实体类
 *
 * @author zhangxa
 * @since 2023-08-21 11:49:59
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "health_xw.t_anticipatory_failure")
@EqualsAndHashCode(callSuper = true)
public class AnticipatoryFailure extends BaseModel<String> {
    @Id
    @ApiModelProperty(value = "主键")
    @Column(name = "id")
    @KeySql(genId = SnowflakeId.class)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /**
     * 节点id
     */
    @Column(name = "node_id")
    @ApiModelProperty(value = "节点id", required = true)
    private Long nodeId;
    /**
     * 异常名称
     */
    @Column(name = "exception_name")
    @ApiModelProperty(value = "异常名称")
    private String exceptionName;
    /**
     * 部件/分系统
     */
    @Column(name = "components")
    @ApiModelProperty(value = "部件/分系统")
    private String components;


    @Transient
    private Long componentsId;

    /**
     * 严重程度
     */
    @Column(name = "serious_degree")
    @ApiModelProperty(value = "严重程度")
    private Integer seriousDegree;

    @Transient
    private String seriousDegreeString;

    public void setSeriousDegree(Integer seriousDegree) {
        this.seriousDegree = seriousDegree;
        this.seriousDegreeString = SeriousDegreeEnum.valueof(seriousDegree);
    }

    public void getSeriousDegreeString(String seriousDegreeString) {
        this.seriousDegreeString = seriousDegreeString;
        this.seriousDegree = SeriousDegreeEnum.valueof(seriousDegreeString);
    }

    /**
     * 卫星id
     */
    @Column(name = "satellite_id")
    @ApiModelProperty(value = "卫星id", required = true)
    private Long satelliteId;

    /**
     * 卫星名称
     */
    @Column(name = "satellite_name")
    @ApiModelProperty(value = "卫星名称", required = true)
    private String satelliteName;

    /**
     * 创建时间
     */
    @Column(name = "created_time")
    @InsertAutoFilling(value = FillingCreateTime.class)
    @ApiModelProperty(value = "创建时间", accessMode = ApiModelProperty.AccessMode.READ_ONLY, example = "2010-01-01 00:00:00")
    private Date createdTime;
    /**
     * 更新时间
     */
    @Column(name = "updated_time")
    @UpdateAutoFilling(value = FillingCreateTime.class)
    @ApiModelProperty(value = "最后更新时间", accessMode = ApiModelProperty.AccessMode.READ_ONLY, example = "2010-01-01 00:00:00")
    private Date updatedTime;
}
